#include "RigidBodySquare.h"
#include "Timer.h"
#include "PhysicsCalculations.h"

RigidBodySquare::RigidBodySquare()
{
	m_rbType = CUBE;
	//m_oobb = new OOBB3();
}

RigidBodySquare::~RigidBodySquare()
{
	//delete m_oobb;
}

void RigidBodySquare::Draw()
{

}

void RigidBodySquare::Update()
{
	static const D3DXVECTOR3 GRAVITY = D3DXVECTOR3(0.0f, -10.0f, 0.0f);
// linear movements
	// calculate acceleration from force and inverse mass

	// calculate velocity from acceleration

	// calculate new position from velocity
	
	m_acceleration = m_force * m_inverseMass;
	if (m_inverseMass > 0)
	{
		m_acceleration += GRAVITY;
	}
	CalculatePositionE(m_position, m_oldVelocity, m_velocity, m_acceleration);

// rotational movements
	m_rotAcceleration = m_torque;	//inverse moment of intertia and total torque
									// can sub moment of interia to a const value scaled
									// to the size of the rigidbody
	m_rotation += m_rotVelocity * TheTimer::Instance()->GetDt();
	m_torque = 0.0f;
	m_force = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
}

//OOBB3 RigidBodySquare::GetOOBB()
//{
//	return m_oobb;
//}
//
//void RigidBodySquare::SetOOBB(const OOBB3& oobb)
//{
//	m_oobb = oobb;
//}